onCommand

open fun onCommand(name: String, value: String)

Invoked when a command is received by a component this listener is registered with.

Implementers should typically use a switch statement or if-else-if chain on the name} parameter to identify the command and then process it accordingly, using the arg} parameter if provided.

The specific set of command names and the expected format or meaning of their arguments are defined by the system or component issuing the commands. Refer to the relevant documentation for available commands and their usage.

Example command handling:

*public void onCommand(String name, String arg) {
    if ("RESTART_PLAYER".equalsIgnoreCase(name)) {
        // Code to restart the player
    } else if ("SET_VOLUME".equalsIgnoreCase(name)) {
        try {
            int volumeLevel = Integer.parseInt(arg);
            // Code to set player volume
        } catch (NumberFormatException e) {
            // Log error: invalid volume argument
        }
    } else if ("NAVIGATE_TO".equalsIgnoreCase(name)) {
        // Code to navigate to a screen or URL specified in 'arg'
    } else {
        // Log: unhandled command
    }
}
Handles incoming commands by forwarding them to the loaded gadget via a JavaScript call and by dispatching a custom DOM event.

It attempts to call a JavaScript function RevelDigital.Controller.onCommand(name, value) and also triggers a DOM event named "RevelDigital.Command" with command details in a JSON string.

Parameters

name

The name of the command.

value

The value or argument associated with the command.